# 1. 执行下列命令连接远程主机rabbitmq

# import pika
# credentials = pika.PlainCredentials('guest', 'guest')
# connection = pika.BlockingConnection(pika.ConnectionParameters('192.168.202.130', 5672, '/', credentials))

# 2. 连接出错
# pika.exceptions.ConnectionClosedByBroker: (403, 'ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.')

# 3. 分析guest用户只能用于localhost登陆

# 4. 创建新用户
# rabbitmqctl add_user test test
# rabbitmqctl set_user_tags test administrator

# 5. 修改上面代码再次进行测试
# access to vhost '/' refused for user

# 6. 出错原因是，用户‘test’没有权限访问‘/’，所以需要进行下面的授权
# sudo rabbitmqctl set_permissions -p / test '.*' '.*' '.*'

# 7. 成功